/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import DAO.ChuDeDAO;
import DAO.WebsiteDAO;
import DAO.XpathDAO;
import DTO.ChuDeDTO;
import DTO.TinTucDTO;
import DTO.WebsiteDTO;
import DTO.XpathDTO;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author QuangHau
 */
public class Xpath extends javax.swing.JDialog {

    private int status;
    public boolean isReset = false;
    private int maXpath;

    /**
     * Creates new form Xpath
     */
    public Xpath(java.awt.Frame parent, boolean modal, int _status, int _maXpath) {
        super(parent, modal);
        initComponents();
        loadCmbWebsite();

        status = _status;
        maXpath = _maXpath;
        if (status == 1) {
            this.setTitle("Cập nhật Xpath");
            btnThem.setText("Cập nhật");
            XpathDTO xpathDTO = XpathDAO.ThongTinXpath(maXpath);
            WebsiteDTO itemWebsite = null;
            for (int i = 0; i < cmbWebsite.getItemCount(); i++) {
                itemWebsite = (WebsiteDTO) cmbWebsite.getItemAt(i);
                if (itemWebsite.getMaWebsite() == xpathDTO.getMaWebsite()) {
                    cmbWebsite.setSelectedIndex(i);
                    ChuDeDTO itemChuDe = null;
                    for (int j = 0; j < cmbChuDe.getItemCount(); j++) {
                        itemChuDe = (ChuDeDTO) cmbChuDe.getItemAt(j);
                        if (itemChuDe.getMaChuDe() == xpathDTO.getMaChuDe()) {
                            cmbChuDe.setSelectedIndex(j);
                            break;
                        }
                    }
                    break;
                }
            }
            txtTenXpath.setText(xpathDTO.getTenXpath());
            txtLink.setText(xpathDTO.getLinkTieuDe());
            txtTinTuc.setText(xpathDTO.getTinTuc());
            txtTieuDe.setText(xpathDTO.getTieuDe());
            txtHinhAnh.setText(xpathDTO.getHinhAnh());
            txtNgayDang.setText(xpathDTO.getNgayDang());
            txtMoTa.setText(xpathDTO.getMoTa());
            txtPhanTrang.setText(xpathDTO.getTrang());
        }
    }

    private void loadCmbWebsite() {
        ArrayList<WebsiteDTO> list = WebsiteDAO.SelectWebsite();
        Object[] items = new Object[list.size()];
        for (int i = 0; i < list.size(); i++) {
            items[i] = list.get(i);
        }
        cmbWebsite.setModel(new DefaultComboBoxModel(items));
        cmbWebsite.setSelectedIndex(0);
    }

    private void loadCmbChuDe(int maWebsite) {
        ArrayList<ChuDeDTO> list = ChuDeDAO.selectByWebsite(maWebsite);
        if (list != null && list.size() > 0) {
            Object[] items = new Object[list.size()];
            for (int i = 0; i < list.size(); i++) {
                items[i] = list.get(i);
            }
            cmbChuDe.setModel(new DefaultComboBoxModel(items));
            setEnabledComponent(true);
            checkEnable();
        } else {
            cmbChuDe.removeAllItems();
            setEnabledComponent(false);
            btnKiemTra.setEnabled(false);
            btnThem.setEnabled(false);
        }
    }

    private void setEnabledComponent(boolean value) {
        cmbChuDe.setEnabled(value);
        txtTenXpath.setEditable(value);
        txtLink.setEditable(value);
        txtTinTuc.setEditable(value);
        txtTieuDe.setEditable(value);
        txtHinhAnh.setEditable(value);
        txtNgayDang.setEditable(value);
        txtMoTa.setEditable(value);
        txtPhanTrang.setEditable(value);
    }

    private void checkEnable() {
        if (txtTenXpath.getText().equals("")
                || txtTinTuc.getText().equals("")
                || txtLink.getText().equals("")
                || txtTieuDe.getText().equals("")) {
            btnKiemTra.setEnabled(false);
            btnThem.setEnabled(false);
        } else {
            btnKiemTra.setEnabled(true);
            btnThem.setEnabled(true);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        txtHinhAnh = new javax.swing.JTextField();
        txtMoTa = new javax.swing.JTextField();
        txtNgayDang = new javax.swing.JTextField();
        txtPhanTrang = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        txtTinTuc = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        txtTieuDe = new javax.swing.JTextField();
        txtTenXpath = new javax.swing.JTextField();
        txtLink = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        cmbWebsite = new javax.swing.JComboBox();
        cmbChuDe = new javax.swing.JComboBox();
        btnKiemTra = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        btnThem = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Thêm Xpath");

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Thông tin xpath"));

        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel5.setText("Website:");

        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel6.setText("Chủ đề:");
        jLabel6.setToolTipText("");

        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel7.setText("Xpath hình ảnh:");

        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel8.setText("Xpath ngày đăng:");

        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel9.setText("Xpath mô tả:");

        jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel10.setText("Xpath phân trang:");

        jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel11.setText("Xpath Tiêu đề:");

        txtTinTuc.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                txtTinTucCaretUpdate(evt);
            }
        });

        jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel12.setText("Xpath link:");

        txtTieuDe.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                txtTieuDeCaretUpdate(evt);
            }
        });

        txtTenXpath.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                txtTenXpathCaretUpdate(evt);
            }
        });

        txtLink.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                txtLinkCaretUpdate(evt);
            }
        });

        jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel13.setText("Xpath tin tức:");
        jLabel13.setToolTipText("");

        jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel14.setText("Tên xpath:");

        cmbWebsite.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbWebsiteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtHinhAnh)
                    .addComponent(txtMoTa)
                    .addComponent(txtTenXpath, javax.swing.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)
                    .addComponent(cmbWebsite, 0, 142, Short.MAX_VALUE)
                    .addComponent(txtTieuDe))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtNgayDang)
                    .addComponent(txtPhanTrang)
                    .addComponent(cmbChuDe, 0, 142, Short.MAX_VALUE)
                    .addComponent(txtTinTuc)
                    .addComponent(txtLink))
                .addContainerGap())
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel11, jLabel14, jLabel5, jLabel7, jLabel9});

        jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel10, jLabel12, jLabel13, jLabel6, jLabel8});

        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(cmbWebsite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbChuDe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel14)
                    .addComponent(jLabel13)
                    .addComponent(txtTenXpath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtTinTuc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12)
                    .addComponent(txtTieuDe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtLink, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8)
                    .addComponent(txtHinhAnh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNgayDang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel9)
                    .addComponent(jLabel10)
                    .addComponent(txtMoTa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtPhanTrang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btnKiemTra.setText("Kiểm tra");
        btnKiemTra.setEnabled(false);
        btnKiemTra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnKiemTraActionPerformed(evt);
            }
        });

        jButton2.setText("Hủy");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        btnThem.setText("Thêm");
        btnThem.setEnabled(false);
        btnThem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnThemActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(btnKiemTra)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnThem)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnKiemTra, btnThem, jButton2});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnKiemTra)
                    .addComponent(jButton2)
                    .addComponent(btnThem))
                .addGap(25, 25, 25))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnKiemTraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnKiemTraActionPerformed
        XpathDTO xpathDTO = new XpathDTO();
        ChuDeDTO chudeDTO = (ChuDeDTO) cmbChuDe.getSelectedItem();
        xpathDTO.setMaChuDe(chudeDTO.getMaChuDe());
        xpathDTO.setTenChuDe(chudeDTO.getTenChuDe());
        xpathDTO.setMaWebsite(chudeDTO.getMaWebsite());
        xpathDTO.setTenWebsite(chudeDTO.getTenWebsite());
        xpathDTO.setLinkChuDe(chudeDTO.getLinkChuDe());
        xpathDTO.setNgayBatDau(chudeDTO.getNgayBatDau());
        xpathDTO.setTenXpath(txtTenXpath.getText());
        xpathDTO.setLinkTieuDe(txtLink.getText());
        xpathDTO.setTinTuc(txtTinTuc.getText());
        xpathDTO.setTieuDe(txtTieuDe.getText());
        xpathDTO.setHinhAnh(txtHinhAnh.getText());
        xpathDTO.setNgayDang(txtNgayDang.getText());
        xpathDTO.setMoTa(txtMoTa.getText());
        xpathDTO.setTrang(txtPhanTrang.getText());

        try {
            ArrayList<TinTucDTO> list = xpathDTO.getNewsOnePage(xpathDTO.getLinkChuDe());
            ArrayList<TinTucDTO> list2 = new ArrayList<TinTucDTO>();
            if (!xpathDTO.getPage().equals("") && !xpathDTO.getPage().equals(xpathDTO.getLinkChuDe())) {
                list2 = xpathDTO.getNewsOnePage(xpathDTO.getPage());
            } else {
                list2 = null;
            }
            Test test = new Test(null, true, new Object[]{list, list2}, 0);
            GUI.ShowCenterScreen(test);
            test.setVisible(true);
        } catch (Exception ex) {
            //Logger.getLogger(Xpath.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null, "Không thể lấy tin.", "Lỗi", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_btnKiemTraActionPerformed

    private void txtTinTucCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtTinTucCaretUpdate
        checkEnable();
    }//GEN-LAST:event_txtTinTucCaretUpdate

    private void txtTieuDeCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtTieuDeCaretUpdate
        checkEnable();
    }//GEN-LAST:event_txtTieuDeCaretUpdate

    private void cmbWebsiteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbWebsiteActionPerformed
        WebsiteDTO item = (WebsiteDTO) cmbWebsite.getSelectedItem();
        loadCmbChuDe(item.getMaWebsite());
    }//GEN-LAST:event_cmbWebsiteActionPerformed

    private void btnThemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnThemActionPerformed
        XpathDTO xpathDTO = new XpathDTO();
        ChuDeDTO chudeDTO = (ChuDeDTO) cmbChuDe.getSelectedItem();
        xpathDTO.setMaChuDe(chudeDTO.getMaChuDe());
        xpathDTO.setTenXpath(txtTenXpath.getText());
        xpathDTO.setLinkTieuDe(txtLink.getText());
        xpathDTO.setTinTuc(txtTinTuc.getText());
        xpathDTO.setTieuDe(txtTieuDe.getText());
        xpathDTO.setHinhAnh(txtHinhAnh.getText());
        xpathDTO.setNgayDang(txtNgayDang.getText());
        xpathDTO.setMoTa(txtMoTa.getText());
        xpathDTO.setTrang(txtPhanTrang.getText());

        if (status == 0) {
            if (XpathDAO.insertXpath(xpathDTO)) {
                JOptionPane.showMessageDialog(null, "Thêm thành công", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
                isReset = true;
                this.dispose();
            } else {
                JOptionPane.showMessageDialog(null, "Thêm thất bại", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
            }
        } else {
            xpathDTO.setMaXpath(maXpath);
            if (XpathDAO.updateXpath(xpathDTO)) {
                JOptionPane.showMessageDialog(null, "Cập nhật thành công", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
                isReset = true;
                this.dispose();
            } else {
                JOptionPane.showMessageDialog(null, "Cập nhật thất bại", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    }//GEN-LAST:event_btnThemActionPerformed

    private void txtTenXpathCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtTenXpathCaretUpdate
        checkEnable();
    }//GEN-LAST:event_txtTenXpathCaretUpdate

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        this.dispose();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void txtLinkCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtLinkCaretUpdate
        checkEnable();
    }//GEN-LAST:event_txtLinkCaretUpdate

    /*
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Xpath dialog = new Xpath(new javax.swing.JFrame(), true, 1, 1);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnKiemTra;
    private javax.swing.JButton btnThem;
    private javax.swing.JComboBox cmbChuDe;
    private javax.swing.JComboBox cmbWebsite;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField txtHinhAnh;
    private javax.swing.JTextField txtLink;
    private javax.swing.JTextField txtMoTa;
    private javax.swing.JTextField txtNgayDang;
    private javax.swing.JTextField txtPhanTrang;
    private javax.swing.JTextField txtTenXpath;
    private javax.swing.JTextField txtTieuDe;
    private javax.swing.JTextField txtTinTuc;
    // End of variables declaration//GEN-END:variables
}
